package com.lq.schoolshop.dao;

import com.github.pagehelper.PageInfo;
import com.lq.schoolshop.pojo.Expand.LoveWallAndLeaveMessage;
import com.lq.schoolshop.pojo.Expand.LoveWallAndPimageAll;
import com.lq.schoolshop.pojo.LoveWall;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author
 * @Date2021/1/8 21:03
 * @Version V1.0
 * 留言墙
 **/
public interface LoveWallMapper {

    //查询全部发布内容
    List<LoveWallAndPimageAll> selListByAll();

    //插入留言内容
    @Insert("INSERT INTO leavemessage VALUES(DEFAULT,#{content},#{uid},NOW(),#{puid})")
    int insertAll(@Param("content") String content,@Param("uid") int uid,@Param("puid") int puid);

    //根据Pid显示用户留言
    @Select("SELECT user.id AS uid,user.name AS uname,user.icon AS icon,leavemessage.createtime AS createtime,leavemessage.content AS content,user.sex AS sex FROM leavemessage,USER WHERE leavemessage.uid=user.id AND puid=#{puid} ORDER BY createtime DESC")
    List<LoveWallAndLeaveMessage> selAllmessageByPid(int puid);


}
